package cn.learn.controller.system.feedback;

import cn.learn.base.BaseController;
import cn.learn.utils.commons.MailUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.mail.MessagingException;

@Controller
@RequestMapping("/system")
public class FeedbackController extends BaseController {

    /**
     * 跳转到反馈页面
     * @return
     */
    @RequestMapping(value = "/feedback", name = "反馈页面")
    public String feedback() {
        return "/system/feedback/show";
    }

    /**
     * 发送邮件
     * @param data
     * @return
     */
    @RequestMapping(value = "/feedSend", name = "发送反馈邮件")
    @ResponseBody
    public String feedSend(String data) {
        try {
            String email = "780631885@qq.com";
            String emailMsg = data;
            MailUtils.sendMail(email,emailMsg);
        } catch (MessagingException e) {
            e.printStackTrace();
            return "0";
        }
        return "1";
    }

}
